﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Net;
using Spike;
using Spike.Network;

namespace HelloSpike
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // Hook the echo event
            Protocol1.Echo += OnEcho;

            // Run the server on the specified endpoints
            Service.Listen(
                new DefaultSpikeTcpBinding(IPAddress.Any, 8002), // Listen on port 8002
                new DefaultSpikeTcpBinding(IPAddress.Any, 80)    // .. and the port 80
                );
        }

        static void OnEcho(IClient client, EchoRequest packet)
        {
            // Simply send back the text we received.
            client.SendEchoInform(packet.Text);
        }
    }
}
